﻿using System;
using System.Diagnostics;
using System.Windows.Forms;

using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace mylibrary
{
    public static class FormHelperClass
    {
        public static void ProcessUnhandledException(Exception ex, string Title)
        {
            string errorMsg = ex.Message;
            MessageBox.Show(errorMsg, "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);

            LogEntry thelog = new LogEntry();

            thelog.EventId = 302;
            thelog.Categories.Add("Exception");
            thelog.Severity = TraceEventType.Error;
            thelog.Priority = 0;
            thelog.Title = Title;
            thelog.Message = errorMsg;
            Logger.Write(thelog);
        }
    }
}
